<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="keywords" content="Hexo Theme Keep">
    <meta name="description" content="Hexo Theme Keep">
    <meta name="author" content="Keep Team">
    
    <title>
        
            Geth安装以及私链搭建 |
        
        Keep Theme
    </title>
    
<link rel="stylesheet" href="/css/style.css">

    <link rel="shortcut icon" href="/images/logo.svg">
    
<link rel="stylesheet" href="/css/font-awesome.min.css">

    <script id="hexo-configurations">
    let KEEP = window.KEEP || {};
    KEEP.hexo_config = {"hostname":"example.com","root":"/","language":"en"};
    KEEP.theme_config = {"toc":{"enable":false,"number":false,"expand_all":false,"init_open":false},"style":{"primary_color":"#0066CC","avatar":"/images/head.png","favicon":"/images/logo.svg","article_img_align":"left","left_side_width":"260px","content_max_width":"920px","hover":{"shadow":false,"scale":false},"first_screen":{"enable":true,"background_img":"/images/pic.jpg","description":"你应该活在自己的热爱里，而不是别人的眼光里。"},"scroll":{"progress_bar":{"enable":false},"percent":{"enable":false}}},"local_search":{"enable":false,"preload":false},"code_copy":{"enable":false,"style":"default"},"pjax":{"enable":false},"lazyload":{"enable":false},"version":"3.4.5"};
    KEEP.language_ago = {"second":"%s seconds ago","minute":"%s minutes ago","hour":"%s hours ago","day":"%s days ago","week":"%s weeks ago","month":"%s months ago","year":"%s years ago"};
  </script>
<meta name="generator" content="Hexo 6.0.0"></head>


<body>
<div class="progress-bar-container">
    

    
</div>


<main class="page-container">

    

    <div class="page-main-content">

        <div class="page-main-content-top">
            <header class="header-wrapper">

    <div class="header-content">
        <div class="left">
            
            <a class="logo-title" href="/">
                Keep Theme
            </a>
        </div>

        <div class="right">
            <div class="pc">
                <ul class="menu-list">
                    
                        <li class="menu-item">
                            <a class=""
                               href="/"
                            >
                                HOME
                            </a>
                        </li>
                    
                        <li class="menu-item">
                            <a class=""
                               href="/archives"
                            >
                                ARCHIVES
                            </a>
                        </li>
                    
                    
                </ul>
            </div>
            <div class="mobile">
                
                <div class="icon-item menu-bar">
                    <div class="menu-bar-middle"></div>
                </div>
            </div>
        </div>
    </div>

    <div class="header-drawer">
        <ul class="drawer-menu-list">
            
                <li class="drawer-menu-item flex-center">
                    <a class=""
                       href="/">HOME</a>
                </li>
            
                <li class="drawer-menu-item flex-center">
                    <a class=""
                       href="/archives">ARCHIVES</a>
                </li>
            
        </ul>
    </div>

    <div class="window-mask"></div>

</header>


        </div>

        <div class="page-main-content-middle">

            <div class="main-content">

                
                    <div class="fade-in-down-animation">
    <div class="article-content-container">

        <div class="article-title">
            <span class="title-hover-animation">Geth安装以及私链搭建</span>
        </div>

        
            <div class="article-header">
                <div class="avatar">
                    <img src="/images/head.png">
                </div>
                <div class="info">
                    <div class="author">
                        <span class="name">Keep Team</span>
                        
                            <span class="author-label">Lv1</span>
                        
                    </div>
                    <div class="meta-info">
                        <div class="article-meta-info">
    <span class="article-date article-meta-item">
        <i class="fas fa-edit"></i>&nbsp;
        <span class="pc">2022-03-07 13:02:17</span>
        <span class="mobile">2022-03-07 13:02</span>
    </span>
    
    

    
    
    
    
</div>

                    </div>
                </div>
            </div>
        

        <div class="article-content markdown-body">
            <ol>
<li>下载geth，网站<a class="link"   target="_blank" rel="noopener" href="https://geth.ethereum.org/downloads/" >https://geth.ethereum.org/downloads/<i class="fas fa-external-link-alt"></i></a></li>
</ol>
<p><img src="C:\Users\86136\AppData\Roaming\Typora\typora-user-images\image-20220419191541228.png" alt="image-20220419191541228"></p>
<p>​            双击安装，直接默认安装的话会在C:&#x2F;Program Files里出现一个Geth文件夹，里面有几个运行程序：</p>
<p><img src="C:\Users\86136\AppData\Roaming\Typora\typora-user-images\image-20220419192014244.png" alt="image-20220419192014244"></p>
<p>​    接下来需要设一下环境变量，打开环境变量设置：</p>
<p><img src="C:\Users\86136\AppData\Roaming\Typora\typora-user-images\image-20220419192419529.png" alt="image-20220419192419529"></p>
<p>cmd打开命令行，输入geth -help，查看安装是否成功：</p>
<p><img src="C:\Users\86136\AppData\Roaming\Typora\typora-user-images\image-20220419192520280.png" alt="image-20220419192520280"></p>
<ol start="2">
<li><p>搭建私链</p>
<ul>
<li><p>在桌面新建一个文本文件，加入下面的创世代码：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br></pre></td><td class="code"><pre><span class="line">&#123;</span><br><span class="line">  &quot;config&quot;: &#123;</span><br><span class="line">        &quot;chainId&quot;: 8, </span><br><span class="line">        &quot;homesteadBlock&quot;: 0,</span><br><span class="line">        &quot;eip155Block&quot;: 0,</span><br><span class="line">        &quot;eip158Block&quot;: 0</span><br><span class="line">    &#125;,</span><br><span class="line">  &quot;alloc&quot;      : &#123;&#125;,</span><br><span class="line">  &quot;coinbase&quot;   : &quot;0x0000000000000000000000000000000000000000&quot;,</span><br><span class="line">  &quot;difficulty&quot; : &quot;0x1&quot;,</span><br><span class="line">  &quot;extraData&quot;  : &quot;&quot;,</span><br><span class="line">  &quot;gasLimit&quot;   : &quot;0x2fefd8&quot;,</span><br><span class="line">  &quot;nonce&quot;      : &quot;0x0000000000000066&quot;,</span><br><span class="line">  &quot;mixhash&quot;    : &quot;0x0000000000000000000000000000000000000000000000000000000000000000&quot;,</span><br><span class="line">  &quot;parentHash&quot; : &quot;0x0000000000000000000000000000000000000000000000000000000000000000&quot;,</span><br><span class="line">  &quot;timestamp&quot;  : &quot;0x00&quot;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>修改后缀为.json，然后拖到刚刚的安装根目录下去（C:&#x2F;Program Files&#x2F;Geth）</p>
<p>在这个目录继续创建一个文件夹命名为testchain</p>
<p><img src="C:\Users\86136\AppData\Roaming\Typora\typora-user-images\image-20220419202740214.png" alt="image-20220419202740214"></p>
<p>管理员方式执行命令geth -datadir testchain init genesis.json初始化创世区块</p>
<p><img src="C:\Users\86136\AppData\Roaming\Typora\typora-user-images\image-20220419203039448.png" alt="image-20220419203039448"></p>
<p>会在对应目录下创建一个testchain文件夹，里面的内容：</p>
<p><img src="C:\Users\86136\AppData\Roaming\Typora\typora-user-images\image-20220419202750241.png" alt="image-20220419202750241"></p>
</li>
</ul>
</li>
</ol>
<p>​                    私链就搭建完毕了。</p>
<ol start="3">
<li><p>启动私链节点</p>
<p>geth –datadir data0 –networkid 7788 -nodiscover console</p>
</li>
</ol>
<p><img src="C:\Users\86136\AppData\Roaming\Typora\typora-user-images\image-20220419203522221.png" alt="image-20220419203522221"></p>
<ol start="4">
<li><p>创建账户</p>
<p>&gt; personal.newAccount()</p>
<p>输入密码即可创建成功</p>
</li>
<li><p>挖矿</p>
<p>&gt;miner.start()</p>
<p>查看余额：eth.getBalance(eth.accounts[0])</p>
</li>
</ol>
<p><img src="C:\Users\86136\AppData\Roaming\Typora\typora-user-images\image-20220419205815966.png" alt="image-20220419205815966"></p>
<p>这篇博客讲的非常详细：<a class="link"   target="_blank" rel="noopener" href="https://blog.csdn.net/weixin_44826468/article/details/121604221" >https://blog.csdn.net/weixin_44826468/article/details/121604221<i class="fas fa-external-link-alt"></i></a></p>

        </div>

        

        

        
            <div class="article-nav">
                
                    <div class="article-prev">
                        <a class="prev"
                           rel="prev"
                           href="/2022/04/11/%E8%93%9D%E6%A1%A5%E5%88%B7%E7%9A%84%E4%B8%80%E4%BA%9B%E5%85%B8%E5%9E%8B%E9%A2%98%E7%9B%AE/"
                        >
                            <span class="left arrow-icon flex-center">
                              <i class="fas fa-chevron-left"></i>
                            </span>
                            <span class="title flex-center">
                                <span class="post-nav-title-item">蓝桥刷的一些典型题目</span>
                                <span class="post-nav-item">Prev posts</span>
                            </span>
                        </a>
                    </div>
                
                
                    <div class="article-next">
                        <a class="next"
                           rel="next"
                           href="/2022/03/07/%E7%AC%AC%E4%B8%80%E7%AF%87%E5%8D%9A%E5%AE%A2%E6%96%87%E7%AB%A0/"
                        >
                            <span class="title flex-center">
                                <span class="post-nav-title-item">第一篇博客——关于HEXO+GITEE</span>
                                <span class="post-nav-item">Next posts</span>
                            </span>
                            <span class="right arrow-icon flex-center">
                              <i class="fas fa-chevron-right"></i>
                            </span>
                        </a>
                    </div>
                
            </div>
        

        
    </div>
</div>


                
            </div>

        </div>

        <div class="page-main-content-bottom">
            <footer class="footer">
    <div class="info-container">
        <div class="copyright-info info-item">
            &copy;
            
              <span>2020</span>
              -
            
            2022&nbsp;<i class="fas fa-heart icon-animate"></i>&nbsp;<a href="/">Keep Team</a>
        </div>
        
        <div class="theme-info info-item">
            Powered by <a target="_blank" href="https://hexo.io">Hexo</a>&nbsp;|&nbsp;Theme&nbsp;<a class="theme-version" target="_blank" href="https://github.com/XPoet/hexo-theme-keep">Keep v3.4.5</a>
        </div>
        
        
    </div>
</footer>

        </div>
    </div>

    
        <div class="post-tools">
            <div class="post-tools-container">
    <ul class="tools-list">
        <!-- TOC aside toggle -->
        

        <!-- go comment -->
        
    </ul>
</div>

        </div>
    

    <div class="right-bottom-side-tools">
        <div class="side-tools-container">
    <ul class="side-tools-list">
        <li class="tools-item tool-font-adjust-plus flex-center">
            <i class="fas fa-search-plus"></i>
        </li>

        <li class="tools-item tool-font-adjust-minus flex-center">
            <i class="fas fa-search-minus"></i>
        </li>

        <li class="tools-item tool-expand-width flex-center">
            <i class="fas fa-arrows-alt-h"></i>
        </li>

        <li class="tools-item tool-dark-light-toggle flex-center">
            <i class="fas fa-moon"></i>
        </li>

        <!-- rss -->
        

        
            <li class="tools-item tool-scroll-to-top flex-center">
                <i class="fas fa-arrow-up"></i>
            </li>
        

        <li class="tools-item tool-scroll-to-bottom flex-center">
            <i class="fas fa-arrow-down"></i>
        </li>
    </ul>

    <ul class="exposed-tools-list">
        <li class="tools-item tool-toggle-show flex-center">
            <i class="fas fa-cog fa-spin"></i>
        </li>
        
    </ul>
</div>

    </div>

    

    <div class="image-viewer-container">
    <img src="">
</div>


    

</main>




<script src="/js/utils.js"></script>

<script src="/js/main.js"></script>

<script src="/js/header-shrink.js"></script>

<script src="/js/back2top.js"></script>

<script src="/js/dark-light-toggle.js"></script>








<div class="post-scripts">
    
</div>



</body>
</html>
